package com.cqcj.login.web;

import com.cqcj.login.pojo.Brand;
import com.cqcj.login.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/updateBrandServlet2")
public class UpdateBrandServlet2 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        BrandService brandService = new BrandService();
        Brand brand = new Brand();
        brand.setId(Integer.valueOf(request.getParameter("id")));
        brand.setBrandname(request.getParameter("brandname"));
        brand.setCompanyname(request.getParameter("companyname"));
        brand.setOrdered(Integer.valueOf(request.getParameter("ordered")));
        brand.setDescription(request.getParameter("description"));
        brand.setStatus(request.getParameter("status"));
        System.out.println(brand);
        brandService.updateBrand(brand);
        System.out.println("更新品牌信息啦！");

        request.getRequestDispatcher("/selectBrandAllServlet").forward(request,response);


    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }


}
